from pyos7 import *

count = 0;
count1 = 0;
if __name__ == '__main__':
    def foo():
        while True:
            global count
            count = count+1
            yield
    def foo2():
        while True:
            global count1
            count1 = count1+1
            yield

    def main():
        child = yield NewTask(foo())
        child1 = yield NewTask(foo2())
        print("sleep time", time.ticks_ms())
        yield SleepTask(1000)
        yield KillTask(child)
        yield KillTask(child1)
        print("exit count=", count, "time=", time.ticks_ms())

    sched = Scheduler()
    sched.new(main())
    sched.mainloop()